package WeekTest01;

import java.util.Arrays;

public class Merge {

	public static void main(String[] args) {
		int[] a1 = { 1, 5, 16 }, a2 = { 3, 4, 6, 7 };
		System.out.println(Arrays.toString(merge(a1, a2)));
	}

	public static int[] merge(int[] a1, int[] a2) {
		int len = a1.length + a2.length;
		int[] a3 = new int[len];
		for (int k = 0; k < a1.length; k++) {
			a3[k] = a1[k];	
		}
		int g = 0; 
		for(int s = a1.length;s<len;s++ ) {
			a3[s]=a2[g];
			g++;
		}
	  // System.out.println(Arrays.toString(a3));
		for(int i = 1; i < len;i++) {      
			for(int j = len-1;j > i-1;j--) {     
				if(a3[j]<a3[j-1]) {       
					int temp=a3[j];         
					a3[j]=a3[j-1];
					a3[j-1]=temp;
				}
			}
			
		}
		return a3;
	}
}


